package com.kehutong.api.action;

import org.coraframework.json.JSONObject;
import org.coraframework.logger.Logger;
import org.coraframework.logger.LoggerFactory;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.util.ReqBody;
import org.coraframework.mvc.util.RequestUtils;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@MvcAction
@ReqMapping("/oau-kht/common")
public class CommonAction {

    private Logger logger = LoggerFactory.getLogger(CommonAction.class);

    @ReqMapping(value="/callBack", reqBody = ReqBody.TEXT)
    public JSONObject testCallBack(HttpServletRequest req) throws IOException {
        String text = RequestUtils.readText(req);
        JSONObject jsonObject = JSONObject.parseObject(text);
        String callBackType = jsonObject.getString("callBackType");
        logger.info("此次事件回调的类型是："+callBackType);
        JSONObject json = new JSONObject();
        json.put("status", "SUCCESS");
        return json ;
    }


}
